<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTicketsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activities', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->string('name');
            $table->string('description')->nullable();
            $table->integer('start_date')->comment('活动开始时间');
            $table->integer('end_date')->comment('活动结束时间');
            $table->string('location')->comment('活动地点');
            $table->string('school',50)->index();
            $table->integer('user_id')->comment('创建者ID');
            $table->tinyInteger('status')->comment('活动状态');
            $table->timestamps();
        });
        Schema::create('tickets', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->integer('activity_id');
            $table->string('number');
            $table->string('type',30);
            $table->tinyInteger('way')->comment('线上or线下');
            $table->string('openid',50)->index()->nullable();
            $table->tinyInteger('status')->comment('状态');
            $table->integer('prize_id')->nullable()->comment('奖品ID');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('activities');
        Schema::drop('tickets');
    }
}
